<template>
  <div class="home">
    <header-top></header-top>
    <nav class="city_nav">
      <div class="city_tip">
        <span>当前定位城市:</span>
        <span>定位不准时, 请在城市列表中选择</span>
      </div>
      <a class="city_current">
        <span>长沙</span>
        <svg class="arrow_right">
          <use
            xmlns:xlink="http://www.w3.org/1999/xlink"
            xlink:href="#arrow-right"
          ></use>
        </svg>
      </a>
      <div class="city_hot">
        <h3>热门城市</h3>
        <ul class="hot_box">
          <li v-for="(item, index) in hotCities" :key="index"></li>
        </ul>
      </div>
    </nav>
  </div>
</template>

<script lang="ts">
import { Options, Vue } from "vue-class-component";
import { ref } from "vue";
import HelloWorld from "@/components/HelloWorld.vue"; // @ is an alias to /src
import headerTop from "@/components/header/head.vue"; // @ is an alias to /src
import { cityGuess } from "@/api/getData";

@Options({
  components: {
    HelloWorld,
    headerTop,
  },
  data() {
    return {};
  },
  methods: {
    getHotCities() {
      cityGuess({ type: "hot" })
        .then((res) => {
          console.log(res);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    created() {
      this.getHotCities();
    },
  },
})
export default class Home extends Vue {
  // hotCities:this.hotCities,
  setup() {
    const hotCities: any = ref(null);
    function getHotCities() {
      cityGuess({ type: "hot" })
        .then((res) => {
          console.log(res);
        })
        .catch((err) => {
          console.log(err);
        });
    }
    getHotCities()
    return {
      hotCities,
    };
  }
}
</script>

<style lang="scss" scoped>
@import "@/style/mixin";

.home {
  padding-top: 1.95rem;
  .city_nav {
    padding-top: 0.4rem;
    .city_tip {
      background-color: #fff;
      @include fj;
      @include wh(100%, 1.5rem);
      line-height: 1.5rem;
      padding: 0 0.4rem;

      // border-top: 1px solid $bc;

      span {
        @include sc(0.5rem, #666);
        height: 100%;
        line-height: 1.5rem;

        + span {
          @include sc(0.475rem, #9f9f9f);
          font-weight: 900;
        }
      }
    }
    .city_current {
      background-color: #fff;
      @include fj;
      align-items: center;
      height: 1.7rem;
      text-align: left;
      border-top: 1px solid $bc;
      border-bottom: 2px solid $bc;
      padding: 0 0.4rem;
      box-shadow: 1px 1px 1px $bc;
      span {
        @include sc(0.7rem, $blue);
      }
      .arrow_right {
        @include wh(0.6rem, 0.6rem);
        fill: #999;
      }
    }
    .city_hot {
      background-color: #fff;
      margin-top: 0.45rem;
      border-top: 2px solid $bc;
      border-bottom: 1px solid $bc;
      height: 1.6rem;
      line-height: 1.6rem;
      h3 {
        font-size: 0.5rem;
        text-align: left;
        padding: 0 0.4rem;
        color: #666;
        font-weight: 400;
      }
    }
  }
}
</style>
